#include <iostream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int *p = new int[n];
    int *s = new int[n];
    for (int i = 0; i < n; ++i) {
        cin >> p[i] >> s[i];
    }

    int count = 0;
    for (int i = 0; i < n; ++i) {
        count += p[i] + s[i];
    }
    if (count <= m) {
        cout << n << endl;
    }
    cout << n-1 << endl;
}